package ffm.database.managers;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import javax.naming.NamingException;

import ffm.database.wrappers.DirectConnectionManager;
import ffm.database.wrappers.TomcatDSWrapper;

public class ConnectionManager {

	public TomcatDSWrapper m_dsWrapper;

	
	public ConnectionManager(Properties pProperties) throws FileNotFoundException, NamingException, IOException
	{
	
		boolean bLocal = Boolean.valueOf( pProperties.getProperty("uselocal"));
		
		if (bLocal)
		{
			String sPlayerDataSourceName 		= pProperties.getProperty("localprops_ffm");
			
			
			m_dsWrapper= new DirectConnectionManager();
			((DirectConnectionManager)m_dsWrapper).Initialise(sPlayerDataSourceName,true);
			
			
			
		}
		else
		{
			
			String sPayerDataSourceName 	= pProperties.getProperty("datasource_ffm");


			m_dsWrapper = new TomcatDSWrapper();
			m_dsWrapper.Initialise(sPayerDataSourceName);
			
		}
	}
	
	
	
	public Connection getWrapperConenction() throws SQLException
	{
		return m_dsWrapper.GetConnection();
	}
}
